<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="include :: header('通知详情')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class=""><!--ibox-content-->
            <div class="row">
                <div class="col-sm-12">
                    <h3 class="text-left" th:text="${message.title}">通知标题</h3>
                    <div class="message-meta text-left" style="margin: 20px 0;">
                        <div class="text-muted">发送人：<span th:text="${message.senderName}">发送人</span></div>
                        <div class="text-muted">发送时间：<span th:text="${@tool.formatLocalDateTime(message.sendTime)}">发送时间</span></div>
                        <span class="badge badge-info" th:text="${@dict.getLabel('sys_message_type', message.messageType)}">通知类型</span>
                        <span class="badge badge-warning" th:text="${@dict.getLabel('sys_message_priority',message.priority)}">优先级</span>
                    </div>
                    
                    <div class="message-content" style="border: 1px solid #eee; padding: 20px; border-radius: 5px; min-height: 200px;">
                        <div th:utext="${message.content}">通知内容</div>
                    </div>
                    <!--
						
                    <div class="message-attachments" th:if="${message.attachments}" style="margin-top: 20px;">
                        <h5>附件：</h5>
                        <div th:each="attachment : ${#strings.split(message.attachments, ',')}">
                            <a th:href="'${attachment}'" th:text="${#strings.substringAfterLast(attachment, '/')}">附件名称</a>
                        </div>
                    </div>
					-->
                    
                    <div class="message-actions text-center" style="margin-top: 30px;">
                        <button type="button" class="btn btn-success" onclick="markAsRead()" th:if="${readStatus == 0}">
                            <i class="fa fa-check"></i> 标记为已读
                        </button>
                        <button type="button" class="btn btn-info" onclick="handleNotice(1)" th:if="${handleStatus == 0}">
                            <i class="fa fa-check-circle"></i> 标记为已处理
                        </button>
                        <button type="button" class="btn btn-warning" onclick="handleNotice(2)" th:if="${handleStatus == 0}">
                            <i class="fa fa-times"></i> 忽略
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

	<th:block th:include="include :: footer" />
	<script th:src="@{/js/pm/issue.js}"></script>
    <script type="text/javascript">
        var receiveId = "[[${receiveId}]]";
		var prefix = ctx + "system/message";
        
        function markAsRead() {
            $.ajax({
                url: prefix + "/mark/read/" + receiveId,
                type: "post",
                success: function(result) {
                    if (result.code == web_status.SUCCESS) {
                        $.modal.msgSuccess("标记成功");
                        $('.btn-success').hide();
                    } else {
                        $.modal.alertError(result.msg);
                    }
                }
            });
        }
        
        function handleNotice(handleStatus) {
            var handleRemark = '';
            if (handleStatus == 1) {
                handleRemark = prompt("请输入处理备注（可选）：");
                if (handleRemark === null) return;
            }
            
            $.ajax({
                url: prefix + "/handle/" + receiveId,
                type: "post",
                data: {
                    handleStatus: handleStatus,
                    handleRemark: handleRemark || ''
                },
                success: function(result) {
                    if (result.code == web_status.SUCCESS) {
                        $.modal.msgSuccess("处理成功");
                        $('.btn-info, .btn-warning').hide();
                    } else {
                        $.modal.alertError(result.msg);
                    }
                }
            });
        }
    </script>
</body>
</html>